package chzhenjia.learn.androidcode.four;

import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import chzhenjia.learn.androidcode.R;

public class MultiDownloadActivity extends AppCompatActivity implements View.OnClickListener {

    private EditText etUrl;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_multi_download);

        etUrl = (EditText) findViewById(R.id.et_url);

        Button btnDownload = (Button) findViewById(R.id.btn_download);
        btnDownload.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_download:
                download();
                break;
        }
    }

    private void download() {
        String url = etUrl.getText().toString().trim();
        MultiDownload download = new MultiDownload(url);
        download.start(Environment.getExternalStorageDirectory());
    }
}
